package com.acme.bankapp.domain.bank;

import com.acme.bankapp.domain.bank.exceptions.NotEnoughFundsException;

public abstract class AbstractAccount implements Account {
	protected double balance;

	public AbstractAccount(double balance) {
		if (balance < 0) {
			throw new IllegalArgumentException(
					"Initial balance should be non-negative");
		}
		this.balance = balance;
	}

	public AbstractAccount() {
		this(0);
	}

	public double getBalance() {
		return balance;
	}

	public double deposit(double sum) throws IllegalArgumentException {
		if (sum <= 0) {
			throw new IllegalArgumentException(
					"Deposit amount should be positive");
		}
			
		balance += sum;

		return balance;
	}

	abstract public void withdraw(double sum) throws NotEnoughFundsException;

	abstract public double maximumAmountToWithdraw();
}
